import com.config.Config;
import com.googlecode.protobuf.format.JsonFormat;
import com.helper.Debug;
import com.helper.ProtoJson;
import com.lua.CallLua;
import com.lua.cache.LuaCache;
import com.nioserver.lib.LuaObj;
import com.proto.TMessage;

public class Run {

    public static void main(String[] args) throws JsonFormat.ParseException {
        new Config("setting.conf");
        LuaObj token = CallLua.getInstance().launch("start/setup");
        LuaCache.getService(token.address).get("setFunc").call(Config.LuaPath);
        LuaObj demo = CallLua.getInstance().launch("demo");

        String val = CallLua.getInstance().call(demo.address,"getJson","");
        Debug.log(val);
        TMessage.Words.Builder wod2 = TMessage.Words.newBuilder();
        TMessage.Body.Builder body = TMessage.Body.newBuilder();
        TMessage.Header.Builder header = TMessage.Header.newBuilder();

        body.addFArr(123);
        body.addIArr(123).addIArr(2);
        body.addSArr("123");
        header.setFunction("Default");
        wod2.setBody(body.build());
        wod2.setHeader(header.build());

        Debug.log(wod2.build().toString());
        String  jw ="{\"Header\":{\"Function\":\"Default\"},\"Body\":{\"FArr\":[1,2],\"IArr\":[1,2],\"SArr\":[\"1\",\"2\"]}}";
//                CallLua.getInstance().launch("demo");
        TMessage.Words wod = ProtoJson.Json2Words(val);

        Debug.log(wod.toString());

        ProtoJson.Proto2Json(wod2.build());

    }
}
